package com.csi.bumblebee.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;

public class CustomLogFormatter extends SimpleFormatter {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public String format(LogRecord record) {
        StringBuilder sb = new StringBuilder();
        sb.append(dateFormat.format(new Date(record.getMillis()))).append(" "); // 格式化时间
        sb.append("[").append(record.getLevel()).append("] "); // 日志级别
        sb.append(record.getMessage()).append("\n"); // 日志信息
        return sb.toString();
    }
}
